--
-- Author: shunguo.chen
-- Date: 2018-06-27 18:59:08
--
-- WorldBlessView 祝福世界
--

local MapBlessIconRender = import(".renders.MapBlessIconRender")

local fileName = string.getModeName(...)
local ClassRef = class(fileName, app.mvc.ViewBase)

ClassRef.VIEW_ROOT_RES = Res.WorldBlessScene

local BLESS_NUM_STR = L("lua_code_text_121")

function ClassRef:init()
	self._ui.Button_close:addClickEventListener(function()
			executeFunc(self._onCloseView, self)
		end)

	local mapPanel = self._ui["Panel/Panel_map"]
	local renders = {0,0,0,0,0}
	for i=1,5 do
		local render = MapBlessIconRender.create(mapPanel:getChildByName("Panel_" .. i))
		render:onBtnClick(handler(self, self._onClickRender))
		renders[i] = render
	end
	self._renders = renders

	self._numText = self._ui["Panel/Panel_bom/tips"]
end

function ClassRef:_onClickRender(render)
	executeFunc(self._onOperate, "openBless", render:getData())
end

-- maps = {MapInfo, ...}
function ClassRef:refresh(maps)
	for i,render in ipairs(self._renders) do
		render:setData(maps[i])
	end
end

function ClassRef:refreshBlessTimes(blessTimes)
	self._numText:setString(string.format(BLESS_NUM_STR, blessTimes))
end

return ClassRef
